'use strict';
const fs = require('fs');

module.exports = {
  // 打印日志
  printLogger(log) {
    this.ctx.logger.info('%j', log);
  },

  // 读取文件目录
  readDir: source => new Promise((resolve, reject) => {
    fs.readdir(source, 'utf8', (err, data) => (err
      ? reject(err)
      : resolve(data)));
  }),

  // 读取文件
  readFile: file => new Promise((resolve, reject) => {
    fs.readFile(file, 'utf8', (err, data) => (err
      ? reject(err)
      : resolve(data)));
  }),
};
